﻿using IdentityServer4.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Yuan.IdentityServer4
{
    public static class Config
    {
        public static IEnumerable<IdentityResource> IdentityResources()
        {
            return new IdentityResource[]
            {
                new IdentityResources.OpenId() ,
                new IdentityResources.Profile()
            };
        }

        public static IEnumerable<ApiScope> ApiScopes()
        {
            return new ApiScope[] { new ApiScope("client_scope1") };
        }


        public static IEnumerable<ApiResource> ApiResources()
        {
            return new ApiResource[]
             {
                new ApiResource("api1","api1")
                {
                    Scopes={"client_scope1" },
                   // UserClaims={}
                }
             };
        }

        public static IEnumerable<Client> Clients()
        {
            return new Client[]
               {
                // m2m client credentials flow client
                new Client
                {
                    ClientId = "credentials_client",
                    ClientName = "Client Credentials Client",
                    AllowedGrantTypes = GrantTypes.ClientCredentials,
                    ClientSecrets = { new Secret("511536EF-F270-4058-80CA-1C89C192F69A".Sha256()) },
                    AllowedScopes = { "client_scope1" },
                    AccessTokenLifetime=10,
                    
                    Claims =new List<ClientClaim>()
                    {
                        new ClientClaim("tenantid","tenantid_value")
                     }
                   },
               };
        }
    }
}
